import Vue from 'vue'
import App from './App.vue'
import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'
import router from './router'

// 配置请求的跟路径
axios.defaults.baseURL = 'http://127.0.0.1'
axios.interceptors.request.use(config => {
        config.headers.PROJECT_PATH = window.sessionStorage.getItem('projectPath')
        config.headers.FROM_TYPE = "PC"
            // 在最后必须 return config
        return config
    })
    // 响应拦截（配置请求回来的信息）
axios.interceptors.response.use(function(response) {
    console.log(response)
        // 处理响应数据

    return response
}, function(error) {
    // 处理响应失败
    return Promise.reject(error)
})

const commonMsg = function(data) {
    if (data.flag == 200) {
        this.$message({
            message: data.uiMessage,
            type: 'success'
        });
    } else {
        this.$message.error(data.uiMessage)
    }
}
Vue.prototype.$commonMsg = commonMsg
Vue.prototype.$http = axios
Vue.use(Element)
Vue.config.productionTip = false

new Vue({
    router,
    render: h => h(App)
}).$mount('#app')